import { ApiProperty } from '@nestjs/swagger'
import { IsString, MinLength, Matches, IsEmail } from 'class-validator'

/**
 * 注册请求体
 */
export class RegisterDto {
  @ApiProperty({ description: '用户名', example: 'admin' })
  @IsString()
  @MinLength(3)
  username: string

  @ApiProperty({ description: '邮箱', example: 'admin@example.com' })
  @IsEmail()
  email: string

  @ApiProperty({ description: '密码', example: 'Admin@123' })
  @IsString()
  @Matches(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&.])[A-Za-z\d@$!%*?&.]{8,}$/, {
    message: '密码必须至少8个字符，包含大小写字母、数字和特殊字符',
  })
  password: string

  /** 图形验证码内容 */
  @ApiProperty({ description: '图形验证码内容', example: 'abcd' })
  @IsString()
  captcha: string

  /** 图形验证码唯一标识 */
  @ApiProperty({ description: '图形验证码唯一标识', example: 'xxxx-xxxx-xxxx-xxxx' })
  @IsString()
  captchaId: string
}
